<template>
  <basic-container>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <avue-crud :data="topicData"
                 :option="option"
                 :page="page"
                 :table-loading="tableLoading"
                 @search-change="searchChange"
                 @size-change="sizeChange"
                 @current-change="currentChange"
                 @search-reset="searchReset"
                 class="avuecrud">

        <!--<template slot-scope="scope" slot="menu">-->
          <!--<div class="menu-title" @click.stop="feedBackDetail(scope.row.topicId)" v-if="scope.row.state == '2'">-->
            <!--<i class="iconfont iconview icon-primary"></i>-->
            <!--<p class="menu-title-text">详情</p>-->
          <!--</div>-->
        <!--</template>-->
      </avue-crud>
    </div>
  </basic-container>
</template>
<script>
  import { mapGetters } from "vuex";
  import {getTopicPage} from "@/api/planning/message";
  export default {
    name: "discussionFinished",
    data() {
      return {
        headerData:{
          title:'会商反馈'
        },
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        tableLoading:false,
        topicData: [],
        option: {
          page: true,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          menu:false,
          refreshBtn: false,
          filterBtn: false,
          menuWidth:100,
          keyId: "id",
          searchBtn:false,
          column: [
            {
              label: "会商标题",
              prop: "title",
              width: 350,
              search:true,
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a style="cursor: pointer;" onclick="feedBackDetail(\'' + row.topicId + '\')">' + value + '</a>';
              }
            },
            {
              label: "会商说明",
              prop: "description",
              cell: true
            }
          ]
        },
        titleLikeSearch:'',
      };
    },
    computed: mapGetters([
      "userInfo"
    ]),
    created(){
      this.getTopicList(this.page);
      window.feedBackDetail = this.feedBackDetail;
    },
    methods: {
      currentChange(currentPage) {
        var page = this.page;
        page.currentPage = currentPage;
        let params = {
          title:this.titleLikeSearch,
        };
        this.getTopicList(page,params);
      },
      sizeChange(pageSize) {
        var page = this.page;
        page.pageSize = pageSize;
        let params = {
          title:this.titleLikeSearch,
        };
        this.getTopicList(page,params);
      },
      getTopicList(page, params) {
        this.tableLoading = true;
        getTopicPage(Object.assign({
          current: page.currentPage,
          size: page.pageSize,
          admins:1,
          userIds:this.userInfo.userId,
          state:'2',
        },params)).then(response => {
          this.topicData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false
        })
      },
      // 清空搜索
      searchReset(){
        this.titleLikeSearch = '';
        let params = {
          title:this.titleLikeSearch,
        };
        this.getTopicList(this.page,params);
      },
      //搜索回调
      // searchChange(params){
      //   this.getTopicList(this.page,this.dealSearchParam(params));
      // },
      // // 处理搜索过滤
      // dealSearchParam(params){
      //   if(params.title){
      //     params.title = params.title;
      //   }
      //
      //   return params;
      // },

      // 反馈
      feedBack(row,index) {
        //   this.$router.$avueRouter.group = item.group;
        this.$router.push({
          path: "/feedBack",
          query:{
            topicId:row.topicId,
            detail:false
          }
        });
      },
      // 详情
      feedBackDetail(topicId) {
        this.$router.push({
          path: "/feedBack",
          query:{
            topicId,
            detail:true
          }
        });
      },
      //搜索回调
      searchChange(params){
        this.tableLoading = true;
        this.titleLikeSearch = params.title;
        getTopicPage({
          current: 1,
          size: this.page.pageSize,
          admins:1,
          userIds:this.userInfo.userId,
          state:'2',
          title:params.title,
        }).then(response => {
          this.topicData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false;
          sessionStorage.setItem('discussionFinished.title',params.title)
        })
      },
    }
  };
</script>

<style lang="scss" scoped>
  .card-border {
    padding: 10px;
    border: 1px solid #d2d2d2;
  }
</style>
